package com.tarena.lbs.user.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tarena.lbs.user.dao.mapper.UserMapper;
import com.tarena.lbs.user.dao.repository.UserRepository;
import com.tarena.lbs.user.pojo.param.UserParam;
import com.tarena.lbs.user.pojo.param.UserTagsParam;
import com.tarena.lbs.user.pojo.po.UserPO;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.User;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Slf4j
public class UserRepositoryImpl implements UserRepository {

    @Autowired
    private UserMapper userMapper;


    @Override
    public UserPO getByPhone(String phone) {
        QueryWrapper<UserPO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("phone",phone);
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public Long countUserByPhone(String phone) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("phone",phone);
        return userMapper.selectCount(queryWrapper);
    }

    //添加客户的注册信息
    @Override
    public void save(UserPO poParam) {
        log.debug("保存用户信息，入参：{}",poParam);
        userMapper.insert(poParam);
    }

    @Override
    public UserPO getById(Integer userId) {
        return userMapper.selectById(userId);
    }

    @Override
    public List<UserPO> listUser(UserParam param) {
        log.debug("查询用户信息", param);
        List<UserPO> list = userMapper.listUser(param);
        return list;
    }

}
